﻿using Newtonsoft.Json;
using System.Net;
using System.Text;
using SkypeBot.Core;

namespace SkypeBot.Commands
{
    public class CoolAdviceCommand : IMessageHandler
    {
        [Message(@"^!ad$|совет$")]
        public Responce SendAdvice(Message message)
        {
            var content = string.Empty;

            using (WebClient mobjWebClient = new WebClient())
            {
                mobjWebClient.Encoding = Encoding.UTF8;
                content = mobjWebClient.DownloadString("http://fucking-great-advice.ru/api/random");
            }

            Content objContent = JsonConvert.DeserializeObject<Content>(content);
            return new Responce(objContent.Text.Replace("&nbsp;", " "));
        }
    }

    public class Content
    {
        public string Id { get; set; }
        public string Text { get; set; }
    }
}
